﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using VersionComparer.DataModel.Assemblies.Images;

namespace VersionComparer.DataModel.Assemblies
{
    [Serializable]
    public class ParameterItem : AssemblyItemBase<ParameterInfo>
    {
        public ParameterItem()
            : base()
        {
        }


        protected override Type AssociatedType(ParameterInfo value)
        {
            return value.ParameterType;
        }
        protected override void Initialize(ParameterInfo value)
        {
            base.Initialize(value);
            Text = value.Name;
            Name = value.Name;
            FullText = string.Format("{2}{0} {1}", UnderlyingTypeName, value.Name, GetAttributesCode()); 
        }

        protected override ComparableItem[] GetChilds(ParameterInfo value)
        {
            return base.GetChilds(value);
        }

        protected override CustomAttributeData[] GetAttributes(ParameterInfo value)
        {
            var result = CustomAttributeData.GetCustomAttributes(value).ToArray();
            return result;
        }

        protected override void BuildRtf(Base.RtfBuilder builder, bool differencesOnly, bool useParentColor)
        {
            BuildAttributesRtf(builder, differencesOnly, useParentColor, false);
            builder.Append(UnderlyingTypeRtf);
            builder.Append(" " + Name);
        }


        protected override System.Drawing.Image GetSpecificImage()
        {
            return AssemblyResources.field;
        }
    }
}
